﻿@model CategoryModel
@{
    Layout = "~/Views/Shared/_ColumnsTwo.cshtml";
    Html.AddTitleParts(!String.IsNullOrEmpty(Model.MetaTitle) ? Model.MetaTitle : Model.Name);
    Html.AddMetaDescriptionParts(Model.MetaDescription);
    Html.AddMetaKeywordParts(Model.MetaKeywords);

    //current category ID
    int currentCategoryId = Model.Id;
}
@using Nop.Core.Domain.Common;
@using Nop.Core.Domain.Seo;
@using Nop.Core.Infrastructure;
@using Nop.Web.Models.Catalog;
@using Nop.Web.Extensions;
@section left{
    @Html.Action("CategoryNavigation", "Catalog", new { currentCategoryId = currentCategoryId, currentProductId = 0 })
}
<div class="clearfix">
    <div class="page-title">
        <h1>@Model.Name</h1>
    </div>
    <div class="promotion-ads">
        <img src="@Url.GetBaseUrl(path: Model.ActivityAdsBannerUrl)" alt=" " />
    </div>
</div>
<div class="page category-page" id="category-page">
    <div class="page-body">
        @*@Html.Widget("categorydetails_top", Model.Id)*@

        @*@Html.Widget("categorydetails_before_subcategories", Model.Id)*@

        <div class="product-selectors clearfix">
            @*view mode*@
            @if (Model.PagingFilteringContext.AllowProductViewModeChanging && Model.Products.Count > 0)
            {
                <div class="product-viewmode">
                    <span>@T("Catalog.ViewMode")</span>
                    @Html.DropDownList("products-viewmode", Model.PagingFilteringContext.AvailableViewModes, new { @class = "form-control", onchange = "location.href=this.value;" })
                </div>
            }
            @*sorting*@
            @if (Model.PagingFilteringContext.AllowProductSorting && Model.Products.Count > 0)
            {
                <div class="product-sorting">
                    <span>@T("Catalog.OrderBy")</span>
                    @Html.DropDownList("products-orderby", Model.PagingFilteringContext.AvailableSortOptions, new { @class = "form-control", onchange = "location.href=this.value;" })
                </div>
            }
            @*page size*@
            @if (Model.PagingFilteringContext.AllowCustomersToSelectPageSize && Model.Products.Count > 0)
            {
                <div class="product-page-size">
                    <span>@T("Catalog.PageSize")</span>
                    @Html.DropDownList("products-pagesize", Model.PagingFilteringContext.PageSizeOptions, new { @class = "form-control", onchange = "location.href=this.value;" })
                    <span>@T("Catalog.PageSize.PerPage")</span>
                </div>
            }
        </div>
        @Html.Widget("categorydetails_before_filters", Model.Id)
        @{
            var priceRangeFilterEnabled = Model.PagingFilteringContext.PriceRangeFilter.Enabled;
            var specificationFilterEnabled = Model.PagingFilteringContext.PriceRangeFilter.Enabled;
        }
        @if (priceRangeFilterEnabled || priceRangeFilterEnabled)
        {
            <div class="product-filters-wrapper panel panel-default">
                <div class="panel-heading">Filters </div>
                <div class="panel-body">
                    @*filtering*@
                    @if (priceRangeFilterEnabled)
                    {
                        @Html.Partial("_FilterPriceBox", Model.PagingFilteringContext.PriceRangeFilter, new ViewDataDictionary())
                    }
                    @*filtering*@
                    @if (specificationFilterEnabled)
                    {
                        @Html.Partial("_FilterSpecsBox", Model.PagingFilteringContext.SpecificationFilter, new ViewDataDictionary())
                    }
                </div>
            </div>
        }
        @*@Html.Widget("categorydetails_before_featured_products", Model.Id)*@

            @*@Html.Widget("categorydetails_after_featured_products", Model.Id)*@

            @*@Html.Widget("categorydetails_before_product_list", Model.Id)*@
            @*product list*@@if (Model.Products.Count > 0)
            {
                if (Model.PagingFilteringContext.ViewMode == "list")
                {
                    @*list mode*@
                    <div class="product-list clearfix">
                        @foreach (var product in Model.Products)
                        {
                            <div class="item-box">
                                @Html.Partial("_ProductBoxActivity2", product, new ViewDataDictionary { { "IsProductListBox", true } })
                            </div>
                        }
                    </div>
                }
                else
                {
                    @*grid mode*@
                    <div class="product-grid clearfix">
                        @foreach (var product in Model.Products)
                        {
                            <div class="item-box">
                                @Html.Partial("_ProductBoxActivity2", product)
                            </div>
                        }
                    </div>
                }
                <script type="text/javascript">
                    seajs.use("common/1.0.0/index", function (app) {
                        app(function () {
                            app("#category-page").on("click", ".product-box-add-to-cart-button", function (evt) {
                                evt.preventDefault();
                                var add2cartLink = app(this).data("addcartlink");
                                app.ajaxCart.addproducttocart_catalog(add2cartLink);
                            });
                        });
                    });
                </script>
            }
            <div class="pager">
                @Html.Pager(Model.PagingFilteringContext).QueryParam("pagenumber")
            </div>
            @*@Html.Widget("categorydetails_bottom", Model.Id)*@
        </div>
    </div>
